import { ApiProperty } from '@nestjs/swagger';
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { Coupon } from '../../coupon/assets/coupon.entity';
import {
  Constant_Enum_Enum_ExCode_ExCodeValue,
  Constant_Enum_Name_ExCode_ExCodeValue,
  IConstant_Enum_Type_ExCode_ExCodeValue,
} from '@/common/constants/enum';

@Entity('excode')
export class ExCode {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  @ApiProperty({ description: '兑换码值' })
  exCodeValue: string;

  @Column({ default: Constant_Enum_Enum_ExCode_ExCodeValue.ExCode_ExCodeValue_Use })
  @ApiProperty({
    default: Constant_Enum_Enum_ExCode_ExCodeValue.ExCode_ExCodeValue_Use,
    description: '兑换码状态' + Constant_Enum_Name_ExCode_ExCodeValue,
    enum: Constant_Enum_Enum_ExCode_ExCodeValue,
  })
  exCodeStatus: IConstant_Enum_Type_ExCode_ExCodeValue;

  @ApiProperty({ description: '优惠券', type: () => Coupon })
  @ManyToOne(() => Coupon, { cascade: ['remove'], onDelete: 'CASCADE' })
  coupon: Coupon;
}
